package org.concept.box.result;

public enum BoxAction {
	TURNLEFT, TURNRIGHT, TURNDOWN, TURNUP;

	public boolean isOpposite(BoxAction action) {
		return isOpposite(this, action);
	}

	public boolean isVertical(BoxAction action) {
		return isVertical(this, action);
	}

	public static boolean isOpposite(BoxAction action1, BoxAction action2) {
		if (action1 == null || action2 == null)
			return false;
		if ((action1 == TURNRIGHT) && action2 == TURNLEFT)
			return true;
		if ((action1 == TURNLEFT) && action2 == TURNRIGHT)
			return true;
		if ((action1 == TURNDOWN) && action2 == TURNUP)
			return true;
		if ((action1 == TURNUP) && action2 == TURNDOWN)
			return true;
		return false;
	}

	public static boolean isVertical(BoxAction action1, BoxAction action2) {
		if (action1 == null || action2 == null)
			return false;
		if ((action1 == TURNRIGHT) && action2 != TURNLEFT)
			return true;
		if ((action1 == TURNLEFT) && action2 != TURNRIGHT)
			return true;
		if ((action1 == TURNDOWN) && action2 != TURNUP)
			return true;
		if ((action1 == TURNUP) && action2 != TURNDOWN)
			return true;
		return false;
	}
}
